<!--
<template>
  <div class="container">
    &lt;!&ndash;    数据大屏展示内容区域&ndash;&gt;
    <div class="screen" ref="screen">
      <Map class="background" />
      &lt;!&ndash;      顶部&ndash;&gt;
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
&lt;!&ndash;        <Map/>&ndash;&gt;
        <div class="left">
          <Tourist class="tourist" />
          <Gender class="gender" />
          <Age class="age" />
        </div>
        <div class="center">
&lt;!&ndash;          <Map class="map" />&ndash;&gt;
          <Line class="line" />
        </div>
        <div class="right">右侧</div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
defineOptions({
  name: 'Screen',
})
// 获取数据大屏展示内容盒子的DOM元素
import { onMounted, ref } from 'vue'
// 引入顶部子组件
import Top from './components/top/index.vue'
// 引入左侧3个子组件
import Tourist from './components/tourist/index.vue'
import Gender from './components/gender/index.vue'
import Age from './components/age/index.vue'
// 引入中间2个子组件
import Map from './components/map/index.vue'
import Line from './components/line/index.vue'

let screen = ref()
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
// 监听视口大小变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
/**
 * 当屏幕宽高比 < 设计稿宽高比，我们需要缩放的比例是屏幕宽度 / 设计稿宽度
 * 当屏幕宽高比 > 设计稿宽高比，我们需要缩放的比例是屏幕高度 / 设计稿高度
 * @param DESIGN_WIDTH
 * @param DESIGN_HEIGHT
 */
const getScale = (DESIGN_WIDTH = 1920, DESIGN_HEIGHT = 1080) => {
  // 实际屏幕大小 / 设计稿大小
  const ww = window.innerWidth / DESIGN_WIDTH
  const wh = window.innerHeight / DESIGN_HEIGHT
  // 取两者中小的那个
  return ww < wh ? ww : wh
}
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  //background-image: linear-gradient(to top, #e6e9f0 0%, #eef1f5 100%);
  //background-image: linear-gradient(to top, #a8edea 0%, #fed6e3 100%);
  background-size: cover;

  .screen {
    width: 1920px;
    height: 1080px;
    //background: red;
    // 接下来利用绝对定位将图表定位到中间位置 ，缩放之后再移动回左上角
    position: fixed;
    left: 50%;
    top: 50%;
    //缩放基点设为左上角
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;
    }

    .bottom {
      display: flex;
      z-index: -2;
      .left {
        z-index: 1;
        width: 30vw;
        flex: 1;
        height: calc(1080px - 40px);
        display: flex;
        flex-direction: column;

        .tourist {
          flex: 1.2;
        }

        .gender {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }

      .center {
        flex: 2;
        display: flex;
        flex-direction: column;

        .map {
          flex: 4;
        }

        .line {
          flex: 1;
        }
      }

      .right {
        flex: 1;
        z-index: 1;
      }
    }
    .background{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 0;
      //background: yellow;
    }
  }
}
</style>
-->
